package com.ruoyi.business.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.TbBusinessMapper;
import com.ruoyi.business.domain.TbBusiness;
import com.ruoyi.business.service.ITbBusinessService;

/**
 * 商机管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-20
 */
@Service
public class TbBusinessServiceImpl extends ServiceImpl<TbBusinessMapper,TbBusiness> implements ITbBusinessService
{

    /**
     * 查询商机管理
     * 
     * @param customerId 商机管理主键
     * @return 商机管理
     */
    @Override
    public TbBusiness selectTbBusinessByCustomerId(Long customerId)
    {
        return baseMapper.selectById(customerId);
    }

    /**
     * 查询商机管理列表
     * 
     * @param tbBusiness 商机管理
     * @return 商机管理
     */
    @Override
    public List<TbBusiness> selectTbBusinessList(TbBusiness tbBusiness)
    {
        LambdaQueryWrapper<TbBusiness> tbBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //姓名模糊查询
        if(StringUtils.isNotEmpty(tbBusiness.getName())){
            tbBusinessLambdaQueryWrapper.like(TbBusiness::getName,tbBusiness.getName());
        }
        return baseMapper.selectList(tbBusinessLambdaQueryWrapper);
    }

    /**
     * 新增商机管理
     * 
     * @param tbBusiness 商机管理
     * @return 结果
     */
    @Override
    public int insertTbBusiness(TbBusiness tbBusiness)
    {
        tbBusiness.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insert(tbBusiness);
    }

    /**
     * 修改商机管理
     * 
     * @param tbBusiness 商机管理
     * @return 结果
     */
    @Override
    public int updateTbBusiness(TbBusiness tbBusiness)
    {
        return baseMapper.updateById(tbBusiness);
    }

    /**
     * 批量删除商机管理
     * 
     * @param customerIds 需要删除的商机管理主键
     * @return 结果
     */
    @Override
    public int deleteTbBusinessByCustomerIds(Long[] customerIds)
    {
        return baseMapper.deleteById(customerIds);
    }

    /**
     * 删除商机管理信息
     * 
     * @param customerId 商机管理主键
     * @return 结果
     */
    @Override
    public int deleteTbBusinessByCustomerId(Long customerId)
    {
        return baseMapper.deleteById(customerId);
    }
}
